/**
 * 
 */
package com.pmsco.pms.core.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.pmsco.pms.core.dao.PmsMenuStructureDao;
import com.pmsco.pms.core.domain.PmsMenuStructure;

/**
 * @author Long Tran
 *
 */
public class PmsMenuStructureDaoImpl extends HibernateDaoSupport implements PmsMenuStructureDao {
	public void saveOrUpdatePmsMenuStructure(PmsMenuStructure pmsMenuStructure) {
		getHibernateTemplate().merge(pmsMenuStructure);
		getHibernateTemplate().flush();
	}

	public List<PmsMenuStructure> listPmsMenuStructure(PmsMenuStructure searchTemplate) {
		List<PmsMenuStructure> ret = new ArrayList<PmsMenuStructure>();
		ret = getHibernateTemplate().findByExample(searchTemplate);
		return ret;
	}

	public PmsMenuStructure loadPmsMenuStructure(PmsMenuStructure searchTemplate) {
		PmsMenuStructure ret = null;
		List<PmsMenuStructure> temp = new ArrayList<PmsMenuStructure>();
		temp = getHibernateTemplate().findByExample(searchTemplate);
		if(temp != null && temp.size() == 1)
			ret = temp.get(0);
		return ret;
	}
	
	public void deletePmsMenuStructure(PmsMenuStructure pmsMenuStructure) {
		getHibernateTemplate().delete(pmsMenuStructure);
		getHibernateTemplate().flush();
	}
}
